package com.demo.service.impl;

import com.demo.dao.AccountMapper;
import com.demo.entity.Account;
import com.demo.service.AccountService;
import com.demo.utils.DaoUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("accountService")
public class AccountServiceImpl implements AccountService {
    @Override
    public int save(Account account) {
        return DaoUtils.execute(sqlSession -> {
            // 执行AddressMapper.find()方法完成查询
            AccountMapper mapper = sqlSession.getMapper(AccountMapper.class);
            return mapper.save(account);
        });
    }

    @Override
    public List<Account> findAll() {
        return DaoUtils.execute(sqlSession -> {
            // 执行AddressMapper.find()方法完成查询
            AccountMapper mapper = sqlSession.getMapper(AccountMapper.class);
            return mapper.findAll();
        });
    }
}
